<template>
  <div class="wrap">
    <div class="top1">
      <dl v-for="item in tablelist" :key="item.id">
        <p class="content1">
          <span class="x">销售额</span>
          <span class="xx">昨日</span>
        </p>
        <div class="big">
          <p>
            <span class="bs">{{ item.num }}</span>
          </p>
          <p>
            <span class="red">
              日环比:
              <span class="reds">{{ item.nums }}%</span>
            </span>
            <span class="lv">
              周环比:
              <span class="lvs">{{ item.numss }}%</span>
            </span>
          </p>
        </div>
        <p class="content2">
          <span class="z">总销售额</span>
          <span class="zz">121947.25元</span>
        </p>
      </dl>
    </div>
    <div class="top2">
      <dl>
        <dt>
          <img src="@img/logo1.png" alt />
        </dt>
        <dd>
          <p>会员管理</p>
        </dd>
      </dl>
      <dl>
        <dt>
          <img src="@img/logo2.png" alt />
        </dt>
        <dd>
          <p>系统管理</p>
        </dd>
      </dl>
      <dl>
        <dt>
          <img src="@img/logo3.png" alt />
        </dt>
        <dd>
          <p>商品</p>
        </dd>
      </dl>
      <dl>
        <dt>
          <img src="@img/logo4.png" alt />
        </dt>
        <dd>
          <p>订单管理</p>
        </dd>
      </dl>
      <dl>
        <dt>
          <img src="@img/logo5.png" alt />
        </dt>
        <dd>
          <p>短信配置</p>
        </dd>
      </dl>
      <dl>
        <dt>
          <img src="@img/logo6.png" alt />
        </dt>
        <dd>
          <p>文章管理</p>
        </dd>
      </dl>
      <dl>
        <dt>
          <img src="@img/logo7.png" alt />
        </dt>
        <dd>
          <p>分销管理</p>
        </dd>
      </dl>
      <dl>
        <dt>
          <img src="@img/logo8.png" alt />
        </dt>
        <dd>
          <p>优惠卷</p>
        </dd>
      </dl>
    </div>
    <div class="top">
      <div id="main" style=" height: 400px"></div>
    </div>
    <div class="top3">
      <div class="lefts">
        <b class="pl">用户</b>
        <div id="mainss" style="width: 600px; height: 350px"></div>
      </div>
      <div class="rights">
        <div id="mains" style="width: 600px; height: 350px"></div>
      </div>
    </div>
  </div>
</template>


<script>
import * as echarts from "echarts";
export default {
  data() {
    return {
      tablelist: [],
      orgOptions: {}
    };
  },
  created() {
    this.$api.tableAdmin().then(res => {
      this.tablelist = res.data.list;
    });
  },
  mounted() {
    var chartDom = document.getElementById("main");
    var chartDoms = document.getElementById("mains");
    var chartDomss = document.getElementById("mainss");

    var myCharts = echarts.init(chartDoms);
    var myChartss = echarts.init(chartDomss);
    var myChart = echarts.init(chartDom);

    var option;
    var options;
    var optionss;

    option = {
      title: {
        text: "订单",
        subtext: "订单量趋势"
      },
      tooltip: {
        trigger: "axis",
        axisPointer: {
          type: "cross"
        }
      },
      toolbox: {
        show: true,
        feature: {
          saveAsImage: {}
        }
      },
      xAxis: {
        type: "category",
        boundaryGap: false,
        data: [
          "00:00",
          "01:15",
          "02:30",
          "03:45",
          "05:00",
          "06:15",
          "07:30",
          "08:45",
          "10:00",
          "11:15",
          "12:30",
          "13:45",
          "15:00",
          "16:15",
          "17:30",
          "18:45",
          "20:00",
          "21:15",
          "22:30",
          "23:45"
        ]
      },
      yAxis: {
        type: "value",
        axisLabel: {
          formatter: "{value} "
        },
        axisPointer: {
          snap: true
        }
      },
      visualMap: {
        show: false,
        dimension: 0,
        pieces: [
          {
            lte: 6,
            color: "	#79FF79"
          },
          {
            gt: 6,
            lte: 8,
            color: "	#79FF79"
          },
          {
            gt: 8,
            lte: 14,
            color: "	#79FF79"
          },
          {
            gt: 14,
            lte: 17,
            color: "	#79FF79"
          },
          {
            gt: 17,
            color: "#79FF79"
          }
        ]
      },
      series: [
        {
          name: "用电量",
          type: "line",
          smooth: true,
          data: [
            10,
            100,
            399,
            350,
            400,
            200,
            150,
            390,
            0,
            0,
            0,
            0,
            50,
            0,
            600,
            500,
            300,
            200,
            600,
            400
          ],
          markArea: {
            itemStyle: {
              color: "#4ABAF9"
            },
            data: [
              [
                {
                  xAxis: "07:30"
                },
                {
                  xAxis: "08:45"
                }
              ],
              [
                {
                  xAxis: "17:30"
                },
                {
                  xAxis: "18:45"
                }
              ],
              [
                {
                  xAxis: "01:15"
                },
                {
                  xAxis: "02:30"
                }
              ],
              [
                {
                  xAxis: "12:30"
                },
                {
                  xAxis: "13:45"
                }
              ]
            ]
          }
        }
      ]
    };
    options = {
      title: {
        text: "购买用户统计",
        subtext: "",
        left: "right"
      },
      tooltip: {
        trigger: "item"
      },
      legend: {
        orient: "vertical",
        left: "left"
      },
      series: [
        {
          name: "访问来源",
          type: "pie",
          radius: "50%",
          data: [
            { value: 1048, name: "未销售用户" },
            { value: 735, name: "消费一次客户" },
            { value: 580, name: "留存客户" },
            { value: 484, name: "回流客户" }
          ],
          emphasis: {
            itemStyle: {
              shadowBlur: 10,
              shadowOffsetX: 0,
              shadowColor: "rgba(0, 0, 0, 0.5)"
            }
          }
        }
      ]
    };
    optionss = {
      xAxis: {
        type: "category",
        boundaryGap: false,
        data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
      },
      yAxis: {
        type: "value"
      },
      series: [
        {
          data: [820, 932, 901, 934, 1290, 1330, 1320],
          type: "line",
          areaStyle: {}
        }
      ]
    };

    option && myChart.setOption(option);

    option && myCharts.setOption(options);
    option && myChartss.setOption(optionss);
  }
};
</script>

<style lang="scss" scoped>
@import "@css/style.scss";
.wrap {
  width: 100%;
  height: auto;
  display: flex;
  flex-direction: column;
  background: #fff;
  .top1 {
    width: 100%;
    display: flex;
    text-align: center;
    dl {
      width: 300px;
      height: 160px;
      background: #fff;
      margin-left: 30px;
      margin-top: 20px;
      box-shadow: 0px 0px 8px #9d9d9d;
      border-radius: 3px;

      .content1 {
        width: 100%;
        height: 25%;
        border-bottom: 1px solid #e0e0e0;
        display: flex;
        /*  line-height: 40px; */
        font-size: 14px;
        .x {
          margin-left: 20px;
          display: inline-block;
          margin-top: 10px;
        }
        .xx {
          margin-left: 140px;
          display: inline-block;
          width: 40px;
          height: 20px;
          margin-top: 10px;
          background: rgb(231, 250, 240);
          color: rgb(93, 210, 158);
          border-radius: 5px;
          font-size: 10px;
          line-height: 20px;
        }
      }
      .content2 {
        width: 100%;
        padding: 0 10px;
        height: 25%;
        border-top: 1px solid #e0e0e0;
        line-height: 40px;
        .z {
          float: left;
          font-size: 12px;
        }
        .zz {
          float: right;
          font-size: 12px;
        }
      }
      .big {
        width: 100%;
        height: 49%;
        padding: 8px;
        .bs {
          font-size: 27px;
          margin-left: -200px;
        }
        .red {
          float: left;
          margin-left: 10px;
          margin-top: 8px;
          font-size: 11px;
          .reds {
            color: red;
          }
        }
        .lv {
          float: right;
          margin-right: 5px;
          margin-top: 8px;
          font-size: 11px;
          .lvs {
            color: rgb(93, 210, 158);
          }
        }
      }
    }
    dl:hover {
      transform: scale(1.05);
    }
  }
  .top2 {
    width: 100%;
    height: 80px;
    text-align: center;
    margin-top: 40px;
    margin-left: 13px;
    display: flex;
    justify-content: space-around;
    dl {
      width: 130px;
      height: 70px;
      background: #fff;
      border-radius: 5px;
      dd {
        width: 100%;
        height: 50%;
        font-size: 10px;
        margin-top: 8px;
      }
      dt {
        width: 100%;
        height: 50%;
        img {
          margin-top: 10px;
        }
      }
    }
  }
  .top3 {
    flex: 1;
    background: #fff;
    margin-left: 25px;
    display: flex;
    .lefts {
      width: 53%;
      height: 100%;
      .pl {
        /* margin-left: -550px; */
      }
    }
    .rights {
      // flex: 1;
      width: 48%;
      height: 100%;
    }
  }
  #main {
    background: #fff;
    // width: 100%;
    margin-left: 25px;
  }
  .top {
    margin-top: 10px;
    width: 100%;
  }
}
</style>